#include <Keypad.h>
#include <BleKeyboard.h>
BleKeyboard bleKeyboard;

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0','1'},
  {'2','3'},
  {'a','b'},
  {'c','d'}
};
byte rowPins[ROWS] = {12, 13, 14, 15}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {2, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleKeyboard.begin();
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
      if(bleKeyboard.isConnected()) {
        // bleKeyboard.write(KEY_RETURN);
        // bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
        // bleKeyboard.press(KEY_LEFT_CTRL);
        // bleKeyboard.press(KEY_LEFT_ALT);
        // bleKeyboard.press(KEY_DELETE);

        bleKeyboard.write(customKey);
        bleKeyboard.releaseAll();
      }
  }
}
